package com.feidee.transformer;

import com.feidee.fdspark.transformer.ColNamer;
import org.jpmml.converter.Feature;
import org.jpmml.sparkml.FeatureConverter;
import org.jpmml.sparkml.SparkMLEncoder;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author songhaicheng
 * @Date 2018/12/21 11:33
 * @Description 重命名字段
 * @Reviewer
 */
public class ColNamerConverter extends FeatureConverter<ColNamer> {
    public ColNamerConverter(ColNamer transformer) {
        super(transformer);
    }

    @Override
    public List<Feature> encodeFeatures(SparkMLEncoder encoder) {
        // 保存将被剔除掉的列的信息
        List<Feature> result = new ArrayList<>();
        for (String col : getTransformer().getCols()) {
            result.addAll(encoder.getFeatures(col));
        }
        return result;
    }
}
